﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>

<sec:authentication property="principal" var="currentPrincipal" scope="page" />

<div class="modal-dialog x-modal-dialog" style="width: 600px; margin-top: 100px;">

  <div class="modal-content" style="height: 450px;">

    <div class="modal-header x-breadcrumb no-bottom-border clearfix">

      <h2><i class="glyphicon glyphicon-search" title="过滤查询"></i>&nbsp;&nbsp;<span>课程管理&nbsp;-&nbsp;过滤查询</span></h2>

      <button type="button" class="close" data-dismiss="modal">&times;</button>

    </div>

    <form class="form-horizontal" method="GET" action="${ctx.host}/year-rounds" data-validate="true">

      <input type="hidden" name="filter" value="true" >
      <input type="hidden" name="status" value="${status}" >
      <input type="hidden" name="courseType" value="${courseType}">
      <input type="hidden" name="site" value="${site}">

      <div class="modal-body" style="height: 300px;">

        <div class="form-group x-form-group">
          <label class="col-xs-4 control-label">学员名称</label>
          <div class="pull-left col-xs-6">
            <input type="text" class="form-control" name="name" value="${param.name}" placeholder="支持模糊查询"/>
          </div>
        </div>
        
        <div class="form-group x-form-group">
          <label class="col-xs-4 control-label">学员手机</label>
          <div class="pull-left col-xs-6">
            <input type="text" class="form-control" name="mobile" value="${param.mobile}" placeholder="请输入手机号" data-validate="phone" />
          </div>
        </div>
        
        <div class="form-group x-form-group">
          <label class="col-xs-4 control-label">是否分组</label>
          <div class="pull-left col-xs-6">
            <select name="group" class="form-control" data-validate="required">
              <option></option>
              <option value="0">否</option>
              <option value="1">是</option>
            </select>
          </div>
        </div>
        
        <div class="form-group x-form-group">
          <label class="col-xs-4 control-label">教练</label>
          <div class="pull-left col-xs-6">
            <select name="coach" class="form-control" data-selected="${param.coach}" data-live-search="true" data-size="5">
              <option></option>
              <c:forEach var="coach" items="${persist.coaches(currentPrincipal.id, site)}" >
                <c:if test="${not coach.value.disabled}">
                  <option value="${coach.key}">${coach.value.name}</option>
                </c:if>
              </c:forEach>
            </select>
          </div>
        </div>
        
        <c:if test="${status == 'ready'}">
          <div class="form-group x-form-group">
            <label class="col-xs-4 control-label">失信</label>
            <div class="pull-left col-xs-6">
              <select name="dishonesty" class="form-control" data-selected="${param.dishonesty}" data-live-search="false" data-size="-1">
                <option></option>
                <option value="1" ${param.dishonesty == '1' ? 'selected' : ''}>是</option>
                <option value="0" ${param.dishonesty == '0' ? 'selected' : ''}>否</option>
              </select>
            </div>
          </div>
        </c:if>
        
      </div>

      <div class="modal-footer">
        <button type="submit" class="btn btn-success btn-shadow btn-shadow-success x-btn">查询</button>&nbsp;&nbsp;&nbsp;&nbsp;
        <button type="button" class="btn btn-default btn-shadow btn-shadow-default x-btn" data-dismiss="modal">取消</button>
      </div>

    </form>

  </div>
</div>
  
<script type="text/javascript">
    
    $(document).ready(function(){
    	
    	$('select[name="group"]').select2({
    	    placeholder : '请选择分组',
    	    minimumResultsForSearch : -1,
    	    allowClear : true,
    	  });

        $('select[name="coach"]').select2({
            placeholder : '请选择教练',
            minimumResultsForSearch : 5,
            allowClear : true
        });
        
        
        $('select[name="dishonesty"]').select2({
            placeholder : '请选择是否失信',
            minimumResultsForSearch : -1,
            allowClear : true
        });
        
        var selectedStatus = $('select[name="coach"]').data('selected');
        $('select[name="coach"]').select2('val', selectedStatus);
        
        var selectedDishonesty = $('select[name="dishonesty"]').data('selected');
        $('select[name="dishonesty"]').select2('val', selectedStatus);
    })
    
  </script>
